package com.guoliang.statisticsService.controller;

import com.guoliang.commonUtils.CommonResult;
import com.guoliang.statisticsService.service.StatisticsDailyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author leo
 * @since 2023-02-01
 */
@RestController
@RequestMapping("/statisticsService/statisticsDaily")
public class StatisticsDailyController {
    @Autowired
    private StatisticsDailyService statisticsDailyService;
    @ApiOperation("生成统计数据")
    @GetMapping("registerNum/{day}")
    public CommonResult registerNum(@PathVariable("day") String day){
        statisticsDailyService.createStaByDay(day);
        return CommonResult.ok();
    }
    @ApiOperation("获取统计数据")
    @GetMapping("getStatistics/{type}/{begin}/{end}")
    public CommonResult getStatistics(@PathVariable("type")String type,@PathVariable("begin")String begin,
                                      @PathVariable("end")String end){
        Map<String,Object> map=statisticsDailyService.getStatistics(type,begin,end);
        return CommonResult.ok().date(map);
    }
}
